feat(mcp): add file output support and return summary#45
Merged
Conversation
Add output_path parameter to search_papers and fetch_paper tools. When output_path is specified, results are written to the file in JSON format, and only a summary is returned to the LLM. Changes: - Add output_path parameter to SearchPapersRequest - Add output_path parameter to FetchPaperRequest - Write results to file when output_path is specified - Return summary instead of full results (e.g., paper titles, count) This reduces token usage while keeping full data accessible in files. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Make output_path a required parameter for both search_papers and fetch_paper tools. Always write results to file and return summary. This removes the old behavior of returning full JSON as text, ensuring consistent file-based output for all tool calls. Changes: - Make output_path required (String instead of Option<String>) - Remove conditional file output logic - Always write to file and return summary Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
output_pathparameter to MCP tools (search_papers,fetch_paper). When specified, results are written to the file in JSON format, and only a summary is returned to the LLM.Problem
Previously, MCP tools returned full results as text, which consumed many tokens for large responses. This was inefficient for LLM interactions.
Solution
output_pathparameter to both toolsoutput_pathis specified:output_pathis not specified:Changes
output_pathparameteroutput_pathparameterExample Usage
Search with file output:
{ "query": "quantum computing", "limit": 10, "output_path": "/tmp/results.json" }Returns:
"Found 10 papers:\nPaper Title 1\nPaper Title 2\n..."Fetch with file output:
{ "id": "2512.04518", "output_path": "/tmp/paper.json" }Returns:
"Fetched paper: Paper Title (5 authors)"Test plan
🤖 Generated with Claude Code